package com.youyi.yyviewsdklibrary.Dialog.impl;

import android.content.Context;
import android.content.res.Resources;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.youyi.yyviewsdklibrary.Dialog.core.AttachPopupView;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnSelectListener;
import com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils;
import com.youyi.yyviewsdklibrary.Dialog.widget.VerticalRecyclerView;
import com.lkx.liandianqinew.R;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.MultiItemTypeAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import java.util.Arrays;

public class AttachListPopupView extends AttachPopupView {
    protected int bindItemLayoutId;
    protected int bindLayoutId;
    protected int contentGravity = 17;
    String[] data;
    int[] iconIds;
    RecyclerView recyclerView;
    private OnSelectListener selectListener;

    public AttachListPopupView(Context context, int i, int i2) {
        super(context);
        this.bindLayoutId = i;
        this.bindItemLayoutId = i2;
        addInnerContent();
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public int getImplLayoutId() {
        int i = this.bindLayoutId;
        return i == 0 ? R.layout._xpopup_attach_impl_list : i;
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void onCreate() {
        super.onCreate();
        RecyclerView recyclerView2 = (RecyclerView) findViewById(R.id.recyclerView);
        this.recyclerView = recyclerView2;
        if (this.bindLayoutId != 0) {
            recyclerView2.setLayoutManager(new LinearLayoutManager(getContext()));
        }
        Context context = getContext();
        int i = this.bindItemLayoutId;
        if (i == 0) {
            i = R.layout._xpopup_adapter_text;
        }
        final CommonAdapter r0 = new CommonAdapter<String>(context, i, Arrays.asList(this.data)) {
            /* class com.youyi.yyviewsdklibrary.Dialog.impl.AttachListPopupView.AnonymousClass1 */

            /* access modifiers changed from: protected */
            public void convert(ViewHolder viewHolder, String str, int i) {
                viewHolder.setText(R.id.tv_text, str);
                ImageView imageView = (ImageView) viewHolder.getView(R.id.iv_image);
                if (AttachListPopupView.this.iconIds == null || AttachListPopupView.this.iconIds.length <= i) {
                    if (imageView != null) {
                        imageView.setVisibility(View.GONE);
                    }
                } else if (imageView != null) {
                    imageView.setVisibility(View.VISIBLE);
                    imageView.setImageResource(AttachListPopupView.this.iconIds[i]);
                }
                if (AttachListPopupView.this.bindItemLayoutId == 0) {
                    if (AttachListPopupView.this.popupInfo.isDarkTheme) {
                        ((TextView) viewHolder.getView(R.id.tv_text)).setTextColor(AttachListPopupView.this.getResources().getColor(R.color._xpopup_white_color));
                    } else {
                        ((TextView) viewHolder.getView(R.id.tv_text)).setTextColor(AttachListPopupView.this.getResources().getColor(R.color._xpopup_dark_color));
                    }
                    ((LinearLayout) viewHolder.getView(R.id._ll_temp)).setGravity(AttachListPopupView.this.contentGravity);
                }
            }
        };
        r0.setOnItemClickListener(new MultiItemTypeAdapter.OnItemClickListener() {
            /* class com.youyi.yyviewsdklibrary.Dialog.impl.AttachListPopupView.AnonymousClass2 */

            @Override // com.zhy.adapter.recyclerview.MultiItemTypeAdapter.OnItemClickListener
            public boolean onItemLongClick(View view, RecyclerView.ViewHolder viewHolder, int i) {
                return false;
            }

            @Override // com.zhy.adapter.recyclerview.MultiItemTypeAdapter.OnItemClickListener
            public void onItemClick(View view, RecyclerView.ViewHolder viewHolder, int i) {
                if (AttachListPopupView.this.selectListener != null) {
                    AttachListPopupView.this.selectListener.onSelect(i, (String) r0.getDatas().get(i));
                }
                if (AttachListPopupView.this.popupInfo.autoDismiss.booleanValue()) {
                    AttachListPopupView.this.dismiss();
                }
            }
        });
        this.recyclerView.setAdapter(r0);
        applyTheme();
    }

    /* access modifiers changed from: protected */
    public void applyTheme() {
        int i;
        if (this.bindLayoutId == 0) {
            if (this.popupInfo.isDarkTheme) {
                applyDarkTheme();
            } else {
                applyLightTheme();
            }
            FrameLayout frameLayout = this.attachPopupContainer;
            Resources resources = getResources();
            if (this.popupInfo.isDarkTheme) {
                i = R.color._xpopup_dark_color;
            } else {
                i = R.color._xpopup_light_color;
            }
            frameLayout.setBackground(XPopupUtils.createDrawable(resources.getColor(i), this.popupInfo.borderRadius));
        }
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void applyDarkTheme() {
        super.applyDarkTheme();
        ((VerticalRecyclerView) this.recyclerView).setupDivider(true);
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void applyLightTheme() {
        super.applyLightTheme();
        ((VerticalRecyclerView) this.recyclerView).setupDivider(false);
    }

    public AttachListPopupView setStringData(String[] strArr, int[] iArr) {
        this.data = strArr;
        this.iconIds = iArr;
        return this;
    }

    public AttachListPopupView setContentGravity(int i) {
        this.contentGravity = i;
        return this;
    }

    public AttachListPopupView setOnSelectListener(OnSelectListener onSelectListener) {
        this.selectListener = onSelectListener;
        return this;
    }
}
